< previous page page_333 next page >

Page 333
    On Error Resume Next
    '
    Dim ws As Workspace
    Dim db As Database
    Dim rsTable As Recordset
    Dim rsDynaset As Recordset
    Dim rsSnapshot As Recordset
    Dim rsTemp As Recordset
    '
    Dim strDBName As String
    Dim strRSTable As String
    Dim strRSDynaset As String
    Dim strRSSnapshot As String
    Dim strMsg As String
    '
    ' init vars
    strDBName = App.Path & "\..\..\data\books5.mdb"
    strRSTable = "Buyers"
    strRSDynaset = "Publishers"
    strRSSnapshot = "Authors"
    '
    ' create ws and open db
    Set ws = DBEngine.Workspaces(0)
    Set db = ws.OpenDatabase(strDBName)
    '
    ' create rs objects
    Set rsTable = db.OpenRecordset(strRSTable, dbOpenTable)
    Set rsDynaset = db.OpenRecordset(strRSDynaset, dbOpenDynaset)
    Set rsSnapshot = db.OpenRecordset(strRSSnapshot, dbOpenSnapshot)
    '
    ' enumerate recordsets in collection
    strMsg = ""
    For Each rsTemp In db.Recordsets
        strMsg = strMsg & rsTemp.Name & vbCrLf
    Next
    '
    MsgBox strMsg, vbInformation, "OpenRS"
    '
End Sub
The code in Listing 9.11 creates three Recordsets, one of each type, and then displays the list of open Recordsets on the form. Save and run the form. Compare your results with those in Figure 9.10.
0333-01.jpg
Figure 9.10.
The results of the
OpenRecordset method.

 
< previous page page_333 next page >

If you like this book, buy it!